<% layout('/layouts/default.html', {title: '课程表管理', libs: ['validate','fileupload','ueditor']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(tcourses.isNewRecord ? '新增课程' : '编辑课程')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${tcourses}" action="${ctx}/zx/course/tcourses/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<div class="row hide">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4">${text('上级课程表')}：</label>
							<div class="col-sm-8">
								<#form:treeselect id="parent" title="${text('上级课程表')}"
									path="parent.id" labelPath="parent.courseTitle"
									url="${ctx}/zx/course/tcourses/treeData?excludeCode=${tcourses.id}"
									class="" allowClear="true" canSelectRoot="true" canSelectParent="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('节点编码')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:hidden path="isNewRecord"/>
							<#form:input path="id" maxlength="50" readonly="${!tcourses.isNewRecord}" class="form-control required abc"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('课程标题')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="courseTitle" maxlength="64" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row hide">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('课程简介')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
							    <#form:textarea path="courseSimple" rows="4" maxlength="200" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">${text('课程封面图')}：</label>
							<div class="col-sm-10">
								<#form:fileupload path="courseCover" 
								id="courseCover" 
								returnPath="true"
								filePathInputId="courseCover"
								maxUploadNum="1"
                                imageMaxWidth='1024'
								imageMaxHeight='768'
								uploadType="image" class="" readonly="false"/>
								<#form:input path="courseCover" name="courseCover" class="form-control hide"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('课程内容')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
							<#form:ueditor path="courseContent" returnPath="true" filePathInputId="courseContent" uploadType="all" height="400" class="required" simpleToolbars="true" readonly="false" outline="false">
			                </#form:ueditor>
							</div>
						</div>
					</div>
				</div>
				
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('课程标签')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							    <#form:checkbox path="courseLabel" dictType="t_course_label_query"  class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('课程分类')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							    <#form:select path="courseItem" dictType="t_course_item_query" blankOption="true" class="form-control" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required">*</span> ${text('讲师')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							    <#form:select path="teacherId" maxlength="255" items="${teacherList}" itemLabel="userName" itemValue="userCode" blankOption="true" class="form-control required select2"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('课程价格')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="coursePrice" class="form-control number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('是否推荐')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							    <#form:radio path="recommend" dictType="sys_yes_no"  class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6 hide">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('课程说明')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="courseExplain" maxlength="10" class="form-control digits"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row hide">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('当前层级排序号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="treeSort" class="form-control digits"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row hide">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注做附件的保存路径')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="1555" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row hide">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">${text('图片上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadImage" bizKey="${tcourses.id}" bizType="tcourses_image"
									uploadType="image" class="" readonly="false"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row hide">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">${text('附件上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadFile" bizKey="${tcourses.id}" bizType="tcourses_file"
									uploadType="all" class="" readonly="false"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('zx:course:tcourses:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.$('#dataGrid').dataGrid('refreshTreeChildren',
							$('#parentCode').val(), '${tcourses.id}');
				});
			}
		}, "json");
    }
});

// 选择上级节点回调方法
function treeselectCallback(id, act, index, layero){
	if (id == 'parent' && (act == 'ok' || act == 'clear')){
		// 创建并初始化下一个节点信息，如：排序号、默认值
		$.get('${ctx}/zx/course/tcourses/createNextNode?parentCode='
				+$('#parentCode').val(), function(data){
			$('#treeSort').val(data.treeSort);
		});
	}
}
</script>